<html>
<head>
  <link rel="stylesheet" media="all" type="text/css" href="play.css" />
  <link rel="stylesheet" media="all" type="text/css" href="layouts.css" />
  <script type="text/javascript" src="basic.js"></script>
  <script type="text/javascript" src="json_call.js"></script>
  <script type="text/javascript" src="sparqlEndpoint.js"></script>
  
   
  </head>

<!--  <body onload="document.getElementById('query').innerHTML = document.getElementById('queries').value; ruleConstrain(document.getElementById('select').value, 'where','where_attr_td',1)">
 --> 
 <body onload="get_projects();get_collections_and_rules(document.getElementById('s3db_deployment').value,'126')">
 <script type="text/javascript" src="wz_tooltip.js"></script>
 <div id="wrapper">
	   
	<div id="header">
		 <div id="logo"><h1>TCGA</h1> <h2>SPARQL endpoint</h2></div>
	</div>
	
	<div id="info">
		<table  border=0>
		
		<tr><td>
		<h3>Information<a id="hide_intro_para" onClick="toggle_links('hide_intro_para', 'intro_paragraph')">(hide)</a></h3>
		
		<div id="intro_paragraph">
		Welcome to the SPARQL endpoint for TCGA. You can:
		<div style='font-size: 14; background-color: #F5F5F5; border:1px; margin: 2em; padding: 5px;'>
		<ul>
			<BR>
			<li><I><B>Jump immediatelly to the <a href="#example_queries">Demo Queries</a></B></I></li>
			<BR>
			<li><I><B>Jump to the <a href="#query_builder">Query Builder</a></B></I></li>
			<BR>
			<li><I><B>Understand <a href="#howtouse">how to build</a> the queries</B></I></li>
			<BR>
		</ul>
		</div>
		<a name="howtouse"><I><B>How to use this interface:</B></I></a>
		You may use this interface to perform complex SPARQL queries on an RDF representation of data from the TCGA project. No knowledge of the data is required to perform these queries. However, to understand how to build them, you will need to understand how the RDF representation of TCGA was achieved: each TCGA element corresponds to an entity from the S3DB Core Model (see <a href="http://s3db.org/coremodel">S3DB Core Model</a> for more information on the S3DB Core Model).<BR><BR>
		The RDF graph that fuels this endpoint is structured according the S3DB Core Model entities: Collections, Items, Rules and Statements. The advantage of this annotation is that entities that belong to the <a href="http://tcga.s3db.org/map" target="new">graph of the domain</a> are annotated as "Collections" (for example, "Sample" is a Collection) or Rules (for example, "GenomicCharacterization-obtainedFrom-Sample" is a Rule) and their instances are annotated as Items (for example, "TCGA-01-0001" is an Item of the collection "Samples) or Statements (for example, "TCGA-01-0001"-"provided"-"GC1234" is as Statement that uses the Rule "GenomicCharacterization-obtainedFrom-Sample"). The TCGA dataset can be explored directly on <A HREF="http://tcga.s3db.org/login" target="new">webS3DB</a> by using "public/public" as username/password.<BR><BR>
		Alternativelly, the "Query builder" menu can be used to browse the Domain (select a Collection from the top menu to view which attributes may be associated with Items of that collection).
		
		
		<BR><BR>
		Also feel free to try the related links:
		<a id="toggle_links" onClick="toggle_links('toggle_links','link_table')">(hide)</a>
		<!-- <a id="hide" onClick="document.getElementById('link_table').style.display='none'">(-)</a>
		<a id="show" onClick="document.getElementById('link_table').style.display='inline'">(+)</a> -->
		<table border=0 id="link_table" style="margin-left: 35; margin-right: 35; display=inline" > 
		<tr>
		<td style="font-family: verdana; font-size: 12; border: 1">
		<ul>
			<li>The <a href="http://tcga.s3db.org/map" target="new">map of the TCGA domain</a></li>
			<li><A HREF="http://tcga.s3db.org/login" target="new">S3DB Deployment used for TCGA data </a>(use username='public' and password='public' for public login
			<li>A <A HREF="http://tcga.s3db.org/TCGAsync.php"  target="new">service to retrieve TCGA genomic characterizations </A> based on their attributes: institution, platform, batch and sample_id (<A HREF="http://tcga.s3db.org/TCGAsync.php?institution=hms.harvard.edu&platform=hg-cgh-244a&sample_id=TCGA-02-0006-01B&batch=1" target="new">for example</A>: institution=hms.harvard.edu, platform=hg-cgh-244a, batch=1,  sample_id=TCGA-02-0006-01B
			<li>The <A HREF="http://tcga.s3db.org/load_code" target="new">code used to populate an S3DB Deployment </A> with the TCGA datasets</li>
			<li>An <a href="http://ibl.mdanderson.org/TCGA/TCGA.rdf">complete RDF/XML representation </a>of the TCGA datasets</li>
			
		</ul>
		</td>
		</tr>
		</table>
		
		 </div>
		<form method="get" action="http://www.sparql.org/sparql">
		<input type="hidden" value="" name="default-graph-uri">
		
		<input type="hidden" value="soft" name="should-sponge">	
		<input type="hidden" value="stylesheet=" name="/xml-to-html.xsl">
		
		</div>
		</td></tr>
		
		<tr><td><h5>For Demo Queries <a href="#example_queries">go directly</a> to the textbox at the bottom of the page!</h5>
		</td></tr>
		<tr><td>
		<div id="builder">
		<span>
		
		<h3>Query Builder<a name="query_builder"></a><a id="toggle_links_builder" onClick="toggle_links('toggle_links_builder','query_builder_table')">(hide)</a></H3>
		Navigate the domain to build a query:<BR><BR>
		</span>
		
		<table border="0" id="query_builder_table">
			<tbody>
			<tr width="100" style="background-color: #EFEFEF">
				<td width="33%" >Specify a deployment and a project. These will populate the query builder with the domain.</td>
				<td width="60%">
				<select id="s3db_deployment" size="3" onClick="if(this.value=='other') {document.getElementById('other_s3db_deployment').style.display='inline';this.id='s3db_deployment_choices';} else {document.getElementById('other_s3db_deployment').style.display='none'}">
					<option value="http://ibl.mdanderson.org/TCGA/" selected="selected">TCGA (public)</option>
					<option value="http://mdadqss3db04/s3db">TCGA (MD Anderson)</option>
					<option value="other">Other...</option>
				</select>
				<input type="text" value="Type the URL of an S3DB deployment" name="s3db_deployment" id="other_s3db_deployment" size="40" onFocus = "this.value=''; this.id='s3db_deployment'" onkeydown="when_enter_grab_public_projects(event)" style="display: none" />
				<!-- mini table with the project data -->
					<div>
                    <table id="projects_table" style='display:none'>
					<tr>
						<td>Projects</td>
						<td id="projects_table_list"></td>
					</tr>
					</table>
                    </div>
				</td>
				<td width="40%">
				<div id="user_password_form">
					<a style="font-size: 10; color:navy" onClick="if(document.getElementById('user_password_form_to_show').style.display='none'){document.getElementById('user_password_form_to_show').style.display='inline';} else {document.getElementById('user_password_form_to_show').style.display='none'}" title="If you want to SPARQL some data that is not public, simply add here your username and password">+ Let me use my account</a>	
				</div>
				<div id="user_password_form_to_show" style="display:none">
					<select id="authority" name="authority">
						<option value="" selected="selected">Using my S3DB account</option>
						<option value="google">Using my google account</option>
						<option value="mdanderson">Using my mdanderson account</option>
					</select><br>
					<input type="text" id="username" value="Type your username" onfocus="document.getElementById('username').value='';"/><br>
					<input type="text" id="password" value="Type your password" onfocus="document.getElementById('password').type='password'; document.getElementById('password').value=''" onkeypress="when_enter_call_api_login(event)"/>
					<input type="button" value="Go!" onclick="when_enter_call_api_login('go')">
					<input type="hidden" id="key" />									 
				</div>
				
				</td>
			</tr>
			
			<tr>
				<td>Alternativelly, choose an RDF representation of the TCGA data</td>
				<td id="from_td">
				<input type="text" value="http://ibl.mdanderson.org/TCGA/TCGA.rdf" name="uri_target" id="uri_target" size="60"></td> 
				
			 </tr>
			 <tr style="background-color: #EFEFEF">
				<td>What type of data are you looking for?
                
                </td>
				
                <td><div id="loading_collections" style="display:inline"><img src="loading.gif"> loading domain description ...</div>
				<div id="select_td" style="display:none"></div></td> 
				<td></td>
				
			 </tr>
			 
			<tr id="attr_value_patterns">
				<td>Choose a collection from the box above to see its rules. Navigate the Rules until a text box appears - you can chose a value for the chosen attribute, or leave it blank. Click "Add Query", the query will appear in the textbox below. </td>
				<td id="value_box_td"><span id="where_attr_td"  style="display:none"></span></td>
				<td>
				<input type="radio" id="and" name="and_or" value="and" checked/>And
				<input type="radio" id="or" name="and_or" value="or"/>Or
				</td>
				
				
			</tr>
			</tbody>
			<tr>
				<td></td>
				<td>
				<input type="radio" name="query_engine" id="query_engine_sparql" value="sparql" onClick="changeFromToRDF()">Use sparql.org
				<input type="radio" name="query_engine" id="query_engine_s3ql" value="s3ql" onClick="changeFromToS3DB()" checked>Serialize to S3QL
				<input type="radio" name="query_engine" id="query_engine_store" value="store" onclick="document.getElementById('format_sel').setAttribute('style', 'display: inline');">Use local diseasome store<br />
				<input type="button" onClick="clearQuery()" value="Clear Query" id='clear_query'>
				<input type="button" id="add_pattern" value="Add Query" onClick="buildPattern()"></td>
			</tr>
		
		 </table>
		</div>
		</td></tr>
		<tr><td>
		<br>
		</td></tr>
		
		<tr><td>
		<span>
		<p>
		<div style='background-color: #F5F5F5; border:1px;'>
		<h3>Demo Queries</h3><a name="example_queries"><BR>
		Choose a query from the list</a>
		
		
		</span>
		<select align='center' id="queries" onChange="fillQueryText(this.value);" size=6>
			<option value=""></option>
			<option value="9">Q1. Integrate genes discovered in TCGA Samples (Freire 2009) with diseases anotated in diseasome</option>
			<option value="8">Q2. List all RawData links from Glioblastoma Copy number results obtained at Memorial Sloan Kettering (Freire 2009) </option>
			<option value="7">Q3. Retrieve all S3DB collections available for query (domain descriptors)</option>
			<option value="10">Q4. List all Glioblastoma multiforme (gbm) Patients</option>
			<option value="11">Q5. List all Samples of type solid tumor</option>
			<option value="5">Q6. List all genomic characterization arrays from patient TCGA-16-0850</option>
			<option value="1">Q7. List the Raw Data files where the data type is expression of miRNA and the ID of the samples that provided them</option>
			<option value='2'>Q8. 
	   List all glioblastoma multiforme patients treated at MD Anderson and their copy number results.</option>
			<option value='13'>Q9. List all S3DB UID mappings</option>
			<option value='12'>Q10. List all instances of mged:BioSource</option>
			<option value='4'>Q11. List all instances of NCI:Technology_Platform</option>
			<!-- <option value='5'>Trim the previous query to those Arrays that were performed on a specific platform (for example, Agilent 8 x 15K Human miRNA)</option>
            <option value='6'>Retrieve all the rules in the domain of discourse of the TCGA project.
           </option> -->
		</select>
		</div>
		</td></tr>
		
		<tr><td>
		
		<textarea cols = 122 rows = 20 id="query" name="query"></textarea>
		</td></tr>
		<tr><td>
	
	<span id='format_sel'>
	Choose the output format:
	<select id='format' name='format'>
		
		<option value='html.http://www.netway-media.com/freedesigns/table/web20.css'>html css table</option>
		<option value='html'>html table</option>
		<option value='tab'>tab delimited</option>
		<option value='sparql-xml'>SPARQL XML</option>
		<option value='rdf'>RDF XML</option>
		<option value='turtle'>Turtle</option>
		<option value='n3'>N3</option>
		<option value='json'>JSONPP</option>
		<option value='xml'>Regular XML</option>
	</select>
	</span>

	<input type="button" value="Run Query" onClick="send_sparql()">
	<input type="button" onClick="clearQuery()" value="Clear Query"><br />
	
	</form>
	</td></tr>
	</table>
	
	



<div id="foot">
		<p>&copy; 2008/07/10 <a href="mailto:helenadeus@gmail.com">Helena F Deus</a>, <a href="mailto:almeida.jonas@gmail.com">Jonas S Almeida</a>.</p>
</div>

</div>
 

 </body>
</html>
